package com.itheima.controller;

import com.itheima.dao.BookDao;
import com.mysql.cj.jdbc.exceptions.MysqlDataTruncation;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.sql.SQLException;

@RestControllerAdvice
public class ExceptionAdviceHandler {

    //dao 层异常
    @ExceptionHandler(DataIntegrityViolationException.class)
    public Result dataIntegrityViolationException (){
        return new Result(Code.DAO_ERR,null,"你输入的数据不合法!");
    }



    @ExceptionHandler(Exception.class)
    public Result exception (){
        return new Result(Code.UNDEFIND_ERR,null,"请求错误,请重试!");
    }
}
